<?php

declare(strict_types=1);

namespace App\Amqp\Consumer;

use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
use Hyperf\Amqp\Message\Type;
use Hyperf\Amqp\Result;
use Hyperf\Amqp\Annotation\Consumer;
use Hyperf\Amqp\Message\ConsumerMessage;
use PhpAmqpLib\Message\AMQPMessage;

//#[Consumer(exchange: 'hyperf', routingKey: 'hyperf', queue: 'hyperf', name: "DelayDirectConsumer", nums: 1)]
#[Consumer( nums: 1)]
class DelayDirectConsumer extends ConsumerMessage
{
    use ProducerDelayedMessageTrait;
    use ConsumerDelayedMessageTrait;
    //delay 延迟对列,必选安装延时插件 https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases
    //Windows下RabbitMQ安装延时插件地址: https://blog.csdn.net/m0_74876729/article/details/141468753
    protected string $exchange = 'ext.hyperf.delay';

    protected ?string $queue = 'queue.hyperf.delay';

    protected Type|string $type = Type::DIRECT; //Type::FANOUT;

    protected string|array $routingKey = '';
    public function consumeMessage($data, AMQPMessage $message): Result
    {
        return Result::ACK;
    }
}
